# 创建人脸集合
face =[{'faceId': '5c8cfcf2-c4d3-4166-bfd3-3c4678eacbce',
  'faceRectangle': {'top': 236, 'left': 1131, 'width': 150, 'height': 150},
  'faceAttributes': {'smile': 0.0,
   'gender': 'male',
   'age': 19.0,
   'glasses': 'NoGlasses',
   'hair': {'bald': 0.05,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 0.98},
     {'color': 'brown', 'confidence': 0.98},
     {'color': 'other', 'confidence': 0.15},
     {'color': 'gray', 'confidence': 0.15},
     {'color': 'blond', 'confidence': 0.09},
     {'color': 'red', 'confidence': 0.09},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '7f64e6b8-1935-496c-ac41-e03f1e807493',
  'faceRectangle': {'top': 248, 'left': 411, 'width': 146, 'height': 146},
  'faceAttributes': {'smile': 0.117,
   'gender': 'male',
   'age': 23.0,
   'glasses': 'NoGlasses',
   'hair': {'bald': 0.08,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'brown', 'confidence': 0.8},
     {'color': 'gray', 'confidence': 0.43},
     {'color': 'other', 'confidence': 0.36},
     {'color': 'blond', 'confidence': 0.07},
     {'color': 'red', 'confidence': 0.02},
     {'color': 'white', 'confidence': 0.0}]}}},
 {'faceId': '35327ed1-2fb5-40fb-bfcf-38ff57637c93',
  'faceRectangle': {'top': 237, 'left': 747, 'width': 142, 'height': 142},
  'faceAttributes': {'smile': 1.0,
   'gender': 'male',
   'age': 18.0,
   'glasses': 'NoGlasses',
   'hair': {'bald': 0.03,
    'invisible': False,
    'hairColor': [{'color': 'black', 'confidence': 1.0},
     {'color': 'brown', 'confidence': 0.98},
     {'color': 'other', 'confidence': 0.13},
     {'color': 'gray', 'confidence': 0.12},
     {'color': 'blond', 'confidence': 0.12},
     {'color': 'red', 'confidence': 0.04},
     {'color': 'white', 'confidence': 0.0}]}}}]

# 创建字典
glasses = {}
smile = {}
hairColor = {}
age = {}
gender = {}

# 添加人脸到字典里面
count = 0
while count < len(face):
    glasses["Person{}".format(count + 1)] = face[count]['faceAttributes']['glasses']
    smile["Person{}".format(count + 1)] = face[count]['faceAttributes']['smile']
    hairColor["Person{}".format(count + 1)] = face[count]['faceAttributes']['hair']['hairColor'][0]['color']
    age["Person{}".format(count + 1)] = face[count]['faceAttributes']['age']
    gender["Person{}".format(count + 1)] = face[count]['faceAttributes']['gender']
    count += 1

# 打印字典
print("眼镜：", glasses)
print("微笑指数：", smile)
print("头发颜色：", hairColor)
print("年龄：", age)
print("性别：", gender)



# 眼镜： {'Person1': 'NoGlasses', 'Person2': 'NoGlasses', 'Person3': 'NoGlasses'}
# 微笑指数： {'Person1': 0.0, 'Person2': 0.117, 'Person3': 1.0}
# 头发颜色： {'Person1': 'black', 'Person2': 'black', 'Person3': 'black'}
# 年龄： {'Person1': 19.0, 'Person2': 23.0, 'Person3': 18.0}
# 性别： {'Person1': 'male', 'Person2': 'male', 'Person3': 'male'}